package com.springboot.cloud.sysadmin.organization.rest;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

import javax.validation.Valid;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.clj.cloud.common.core.entity.vo.Result;
import com.springboot.cloud.sysadmin.organization.entity.form.RoleForm;
import com.springboot.cloud.sysadmin.organization.entity.po.Role;
import com.springboot.cloud.sysadmin.organization.service.IRoleService;

@RestController
@RequestMapping("/role")
@Api("role")
@Slf4j
public class RoleController {

    @Autowired
    private IRoleService roleService;

    @ApiOperation(value="新增角色",notes="新增一个角色")
    @ApiImplicitParam(name="roleForm",value="新增角色form表单",required=true,dataType="RoleForm")
    @PostMapping
    public Result add(@Valid @RequestBody RoleForm roleForm){
        log.debug("name:{}", roleForm);
        Role role = roleForm.toPo(Role.class);
        return Result.success(roleService.add(role));
    }
    
}
